package cate.common.table.farm.spicefb.row;

import cate.common.table.ERow;
import cate.common.table.XSSFRowWrap;
import easy.java.dev.note.NoteClass;
import easy.java.dev.note.NoteField;
import org.apache.commons.lang3.StringUtils;

import java.util.ArrayList;
import java.util.List;

@NoteClass(value = "水晶峡谷关卡")
public class SpiceFbLevelRow extends ERow {

    @NoteField(value = "关卡")
    public int level;

    @NoteField(value = "章节")
    public int chapter;

    @NoteField(value = "首通奖励")
    public String firstRewardStr;

    @NoteField(value = "怪物配置")
    public String monsterConf;

    @NoteField(value = "挑战ID")
    private String challengeStr;

    @Override
    public void parse(XSSFRowWrap xrw) {
        super.parse(xrw);
        this.id = xrw.getInteger("ID");
        this.level = xrw.getInteger("ID");
        this.chapter = xrw.getInteger("章节", 1);
        this.firstRewardStr = xrw.getString("首通奖励");
        this.monsterConf = xrw.getString("怪物配置");
        this.challengeStr = xrw.getString("挑战ID");
    }

    public List<Integer> challengeIds;

    @Override
    public void decode() {
        challengeIds = new ArrayList<>();
        if (StringUtils.isNotBlank(challengeStr)) {
            String[] split = challengeStr.split(":");
            for (String str : split) {
                challengeIds.add(Integer.parseInt(str));
            }
        }
    }
}
